/*
 * Copyright 2007 Jeffrey Palm
 */

abstract class Token {

  private int line = -1;
  private int col  = -1;

  final void setLine(int line) {this.line = line;}
  final void setCol(int col) {this.col = col;}

  public final int getLine() {return line;}
  public final int getCol() {return col;}
  
  public abstract Type getType();
  public abstract String getString();

  public final String toString() {
    return getType() + ":" + getString() + " @ (" + getLine() + "," + getCol() + ")";
  }

  static class Str extends Token {
    private final String val;
    Str(String val) {this.val = val;}
    public Type getType() {return Type.STRING;}
    public String getString() {return val;}
  }

  static class Number extends Token {
    private final double val;
    Number(String val) {this(Double.parseDouble(val));}
    Number(double val) {this.val = val;}
    public Type getType() {return Type.NUMBER;}
    public String getString() {return String.valueOf(val);}
  }

  static class Delim extends Token {
    private final char val;
    Delim(char val) {this.val = val;}
    public Type getType() {return Type.DELIM;}
    public String getString() {return String.valueOf(val);}
  }

  public static class Type {
    private final String s;
    private Type(String s) {this.s = s;}
    
    public final static Type STRING = new Type("string");
    public final static Type NUMBER = new Type("number");
    public final static Type DELIM  = new Type("delim");

    public String toString() {return s;}
  }
  
}